﻿using GalFrameWork.Pages;
using GalFrameWork.Service;

namespace GalFrameWork;

public partial class AppShell : Shell
{
	public AppShell()
	{

        InitializeComponent();

        var serviceLocatorName = nameof(ServiceLocator);
        var serviceLocator =
            (ServiceLocator)Application.Current.Resources.MergedDictionaries
                .First(p => p.ContainsKey(serviceLocatorName))[
                    serviceLocatorName];


        var routeService = serviceLocator.RouteService;

        var gamestart = "开始游戏";
        var gameedit = "编辑游戏";
        var setup = "设置";
        var sceneedit = "编辑场景";


        Items.Add(new FlyoutItem
        {
            Title = gamestart,
            Route = routeService.GetRoute(RootNavigationConstant.GameStartPage),
            Items = {
                new ShellContent {
                    ContentTemplate = new DataTemplate(typeof(GameStartPage))
                }
            }
        });

        Items.Add(new FlyoutItem
        {
            Title = gameedit,
            Route = routeService.GetRoute(RootNavigationConstant.GameEditPage),
            Items = {
                new ShellContent {
                    ContentTemplate = new DataTemplate(typeof(GameEditPage))
                }
            }
        });
        Items.Add(new FlyoutItem
        {
            Title = setup,
            Route = routeService.GetRoute(RootNavigationConstant.SetUpPage),
            Items = {
                new ShellContent {
                    ContentTemplate = new DataTemplate(typeof(SetUpPage))
                }
            }
        });

        Items.Add(new FlyoutItem
        {
            Title = sceneedit,
            Route = routeService.GetRoute(RootNavigationConstant.SceneEditPage),
            Items = {
                new ShellContent {
                    ContentTemplate = new DataTemplate(typeof(SceneEditPage))
                }
            }
        });


    }
}
